package org.water.sys.entity;
// Generated 2016-3-4 13:17:55 by Hibernate Tools 3.2.2.GA

import java.util.Date;
import java.util.HashMap;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.water.base.entity.AbstractEntity;
import org.water.base.entity.IdEntity;

/**
 * 
 * @author qzy
 *
 */
@Cacheable
@Entity
@Table(name="sys_user")
public class SysUser  extends IdEntity  {
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2748545622999366819L;

	/**
	 * id自动生成
	 */
	/**@Id
	@GeneratedValue(generator="idGenerator")
	@GenericGenerator(name="idGenerator", strategy="org.hibernate.id.UUIDGenerator")
	private String id;

	@Override
    public String getId() {
        return id;
    }
	
    @Override
    public void setId(String id) {
        this.id = id;
    }**/

	/** 
	 * 用户名.
	 */
	@Column(name="user_name")
	private String userName;

	/** 
	 * 别名,如果存在，显示时则显示别名，否则显示用户名.
	 */
	@Column(name="alias_name")
	private String aliasName;

	/** 
	 * 1-男，2-女.
	 */
	@Column(name="sex")
	private Integer sex;
	@Transient
	private String sexName;

	/** 
	 * 手机.
	 */
	@Column(name="phone")
	private String phone;

	/** 
	 * qq.
	 */
	@Length(min=4,max=15)
	@Column(name="qq")
	private String qq;

	/** 
	 * 邮箱.
	 */
	@Email
	@Column(name="email")
	private String email;

	/**
	 * 备注
	 */
	@Column(name="remark")
	private String remark;

	/** 
	 * 是否可以把自己拥有的资源分配给其他用户（也是通过新增角色的方式进行传递），实现资源的传递。0-否，1-是.
	 */
	@Column(name="authable")
	private Integer authable;

	/** 
	 * 创建人.
	 */
	@Column(name="create_user")
	private String createUser;

	/** 
	 * 创建时间.
	 */
	@Column(name="create_date")
	private Date createDate;

	/** 
	 * 0-正常，1-删除.
	 */
	@Column(name="del_status")
	private Integer delStatus;
	/**
	 * 密码
	 */
	@Column(name="password")
	private String password;
	
	/**
	 * 启用状态  1-启用 0-禁用
	 */
	@Column(name="usable")
	private Integer usable;
	@Transient
	private String usableName;
	/**
	 * 出生日期
	 */
	@Column(name="birth_day")
	private Date birthDay;
	
	/**
	 * 机构编码
	 */
	@Column(name="org_code")
	private String orgCode;

	public SysUser() {
	}

	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getAliasName() {
		return this.aliasName;
	}

	public void setAliasName(String aliasName) {
		this.aliasName = aliasName;
	}

	public Integer getSex() {
		return this.sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getQq() {
		return this.qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}


	public Integer getAuthable() {
		return this.authable;
	}

	public void setAuthable(Integer authable) {
		this.authable = authable;
	}

	public String getCreateUser() {
		return this.createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Integer getDelStatus() {
		return this.delStatus;
	}

	public void setDelStatus(Integer delStatus) {
		this.delStatus = delStatus;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public Integer getUsable() {
		return usable;
	}

	public void setUsable(Integer usable) {
		this.usable = usable;
	}

	public Date getBirthDay() {
		return birthDay;
	}

	public void setBirthDay(Date birthDay) {
		this.birthDay = birthDay;
	}
    
	
	
	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public String getSexName()
	{
		sexName="";
		if(sex==null)
		{
			sexName="";
		}
		else if(sex==1)
		{
			sexName="男";
		}
		else if(sex==2)
		{
			sexName="女";
		}
		return sexName;
	}
	
	public String getUsableName()
	{
		if(1==usable)
		{
			usableName="启用";
		}
		else if(0==usable)
		{
			usableName="禁用";
		}
		return usableName;
	}
    /**
     * 验证密码是否正确
     * @param pwd
     * @return
     */
	public boolean pwdIsCorrect(String pwd)
	{
		boolean f=false;
		if(pwd.equals(password)) f=true;
		return f;
	}
	
}
